{% from "macros.jinja" import panel_jsontree, panel_jsontree_js, render_trees %}
{% extends "base_logged.html" %}

{% block page %}
<div id="page-wrapper">


<div class="row">
  <div class="col-lg-12">
    <h1>{{ minion_details.name }} details</h1>
    <ol class="breadcrumb">
      <li><a href="{{ url_for('index') }}"><i class="fa fa-dashboard"></i> SaltPad</a></li>
      <li><a href="{{ url_for('minions_status') }}"><i class="fa fa-cloud"></i> Minions</a></li>
      <li class="active"><i class="fa fa-tags"></i> {{ minion_details.name }} details</li>
    </ol>
  </div>
</div><!-- /.row -->

{% if minion_details.status == 'down' %}
<div class="row">
  <div class="col-lg-12">
    <div class="alert alert-danger"><h2><i class="fa fa-times"></i> Minion seems to be down.</h2></div>
  </div>
</div><!-- /.row -->
{% else %}
<div class="row">
  <div class="col-lg-12">
    <div class="alert alert-success"><h2><i class="fa fa-check"></i> Minion is up and responding.</h2></div>
  </div>

</div><!-- /.row -->


{{ panel_jsontree('Grains',  minion_details.return[0], False, heading_level=2)|safe }}

{% endif %}


<div class="panel panel-default">
  <div class="panel-heading"><h2>Latest jobs</h2></div>
    <div class="panel-body">
    </div>
</div>

<div class="panel panel-danger">
  <div class="panel-heading"><h2>Manage minion key</h2></div>
    <div class="panel-body">
      <a href="{{ url_for('delete_key', key=minion_details.name) }}">
          <button type="button" class="btn btn-danger">
            Delete key
          </button>
      </a>
      <a href="{{ url_for('reject_key', key=minion_details.name) }}">
          <button type="button" class="btn btn-danger">
            Reject key
          </button>
    </div>
</div>

{% endblock %}

{% block scripts %}
{% if minion_details.status == 'up' %}

<script type="text/javascript">
{{ panel_jsontree_js()|safe }}
{{ render_trees()|safe }}
</script>

{% endif %}
{% endblock %}
